package com.njbdqn.myfilm.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import com.njbdqn.myfilm.componses.IPageDAO;
import com.njbdqn.myfilm.componses.PageParam;
import com.njbdqn.myfilm.vo.Display;

public interface DisplayDAO extends IPageDAO<Display> {
	@Insert("insert into actorandfilm(actorid,filmid,playdate) values(#{actorid},#{filmid},now())")
	public void save(List<Display> displays);
	@Select("select * from actor")
	public List<Display> findAllActor();
	@Select("select * from film")
	public List<Display> findAllFilm();
	@Select("select ceil(count(*)/#{pageSize}) from (select * from actorandfilm group by filmid) aaf")
	public int getCountPage(PageParam pip);
	@Select("select group_concat(a.actorname separator' / ') actorname,f.filmid,f.filmname,f.info,aaf.playdate from actorandfilm aaf join film f on aaf.filmid=f.filmid join actor a on aaf.actorid=a.actorid group by f.filmid,f.filmname,aaf.playdate order by aaf.playdate desc limit ${cpval}")
	public List<Display> findCurrentPageData(PageParam pip);
}
